package com.condominio.listener;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

import com.condominio.facade.Facade;
import com.condominio.model.Pessoa;

/**
 * Application Lifecycle Listener implementation class 

AdminContextListener
 *
 */
public class AdminContextListener implements ServletContextListener {
	Facade fachada=Facade.getInstance();

	public void contextInitialized(ServletContextEvent event) {
		Pessoa admin=new Pessoa();
		admin.setNome("Admin geral do sistema");
		admin.setLogin("admin");
		admin.setSenha("senha");
		admin.setPrivilegio(1);
		event.getServletContext().setAttribute("administrador", 

admin);
		try{
		fachada.cadastrarPessoa(admin);
		}catch (Exception e) {
			e.printStackTrace();
			return;
		}
    }

	/**
     * @see ServletContextListener#contextDestroyed(ServletContextEvent)
     */
    public void contextDestroyed(ServletContextEvent arg0) {
        // TODO Auto-generated method stub
    }
	
}
